<?php
// 永不超时     用命令行  因为apache  nginx 自带超时
set_time_limit(0);
// __DIR__ 表示文件所在目录
include __DIR__ . '/function.php';
require __DIR__ . '/vendor/autoload.php';

use QL\QueryList;

$db = new PDO('mysql:host=localhost;dbname=zufang;charset=utf8mb4', 'root', 'root');
// url地址
$sql = "select id,url from zfw_articles where body=''";
$row = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC);

foreach ($row as $item) {
    $url = $item['url'];
    // html
    $html = http_request($url);

// lj-lazy
    $ret  = QueryList::Query($html, [
        'body' => ['.m-article .bd', 'html'],
    ])->data;
    $body = $ret[0]['body'];

    $spl  = "update zfw_articles set body=? where id={$item['id']}";
    $stmt = $db->prepare($spl);
    // 入库
    $stmt->execute([$body]);
}






